<?php
/**
 * Created by PhpStorm.
 * User: yuanzh
 * Date: 2017-02-09
 * Time: 11:31
 */
namespace srvs;

use LeanCloud\Object;
use LeanCloud\Query;
use srvs\web\BaseService;

class TestObjectService extends  BaseService {

    public static $fileds=["words"];

    public function getAllTestObject(){
        $query = new Query("TestObject");
        $datalist = $query->find();
        return $this->decodeObject($datalist);
    }

    public function getOneTestObject(){
        $query = new Query("TestObject");
        $datalist = $query->find();
        return $this->decodeObject(current($datalist));
    }

    public function insert(){
        $testObject = new Object("TestObject");
        $testObject->set("words", "Hello World!");
        try {
            $testObject->save();
            return "Save object success!";
        } catch (\Exception $ex) {
            return "Save object fail!";
        }
    }
}